package com.ds.service.userService;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.ds.mapper.UserMapper;
import com.ds.pojo.User;
import com.ds.util.MD5Utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.UUID;

/**
 * @author wzy
 * @version 1.0
 * @date 2022/5/23 20:56
 */

@Service
@DS("db1")//指定数据库
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    private String userId;

    @Override
    public String findUser(User user) {
        String pwd = user.getPassword();
        String md5Pwd = MD5Utils.encryptToMD5(pwd);
        user.setPassword(md5Pwd);
        User userInfo = userMapper.getUserByName(user);
        if (userInfo == null){
            return null;
        }
        String token = user.getAccountname();
        return token;
    }

    @Override
    public String getUidByName(String accountname) {
        return userMapper.getUidByName(accountname);
    }
}
